// JavaScript Document
function trim(str) {
	return str.replace(/(^\s*)|(\s*$)/g, "");

}
function showf(s) {
	var showtext = document.getElementById("showtext");
	var hidetext = document.getElementById("hidetext");
	if (s == 1) {
		showtext.style.display = 'block';
		hidetext.style.display = 'none';
	} else if (s == 2) {
		showtext.style.display = 'none';
		hidetext.style.display = 'block';
		hidetext.innerHTML = '<input type="text" id="inputtext"/>';
	}
}

function subm() {
	var date = new Date();
	var now = "";
	now = date.getFullYear() + "年";
	now = now + (date.getMonth() + 1) + "月";
	now = now + date.getDate() + "日 ";
	now = now + date.getHours() + ":";
	now = now + date.getMinutes() + ":";
	now = now + date.getSeconds();

	var ti = now;
	var shar = document.getElementById("sh");
	var ss = document.getElementById("ss");
	var su = document.getElementById("su");
	var inputtext = document.getElementById("inputtext");
	if (shar.checked) {
		if (confirm("宿舍号:3#505，是否分配")) {
			ss.style.display = 'block';
			su.style.display = 'none';
			document.getElementById("time").innerHTML = ti;
			document.getElementById("showtext").innerHTML = "3#505";
			document.getElementById("shar1").style.display = 'none';
			document.getElementById("shar2").style.display = 'none';
		}
	} else {
		if (trim(inputtext.value) == "") {
			alert("你输入的内容为空");
		} else {
			if (confirm("是否确定")) {
				ss.style.display = 'block';
				su.style.display = 'none';
				document.getElementById("time").innerHTML = ti;
				document.getElementById("showtext").innerHTML = document
						.getElementById("inputtext").value;
				document.getElementById("shar1").style.display = 'none';
				document.getElementById("shar2").style.display = 'none';
				document.getElementById("hidetext").innerHTML = inputtext.value;
			}
		}
	}
}
function addf() {
	document.getElementById("shar1").style.display = 'block';
	document.getElementById("shar2").style.display = 'block';
	document.getElementById("showtext").style.display = 'block';
	document.getElementById("su").style.display = 'block';
	document.getElementById("ss").style.display = 'none';
	document.getElementById("hidetext").style.display = 'none';
	document.getElementById("showtext").innerHTML = "未分配";
}
function showmenu(ob, sum) {
	var aa = document.getElementById("menutop").getElementsByTagName("li");
	for ( var i = 0; i <= sum; i++) {
		aa[i].style.backgroundImage = '';
	}
	ob.style.backgroundImage = 'url("images/menu_bg.jpg")';
	return false;
}
window.onload = function() {
	var li = document.getElementById("menutop").getElementsByTagName("li");
	for ( var i = 0; i < li.length; i++) {
		li[i].onmouseover = function() {
			this.style.backgroundImage = 'url("images/menu_bg.jpg")';
		}
		li[i].onmouseout = function() {
			this.style.backgroundImage = '';
		}
	}
}
